//
//  MessageViewController.m
//  NoneCar
//
//  Created by DongSen on 2018/7/10.
//  Copyright © 2018年 董森森. All rights reserved.
//

#import "BaseViewController.h"
#import "MLMSegmentManager.h"
#import "AllMessageViewController.h"
#import "MessageViewController.h"

@interface MessageViewController ()
{
    NSArray *list;
}
@property (nonatomic, strong) MLMSegmentHead *segHead;
@property (nonatomic, strong) MLMSegmentScroll *segScroll;
@end

@implementation MessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self segmentStyle];
    [self.navigationController.navigationBar  setBackgroundImage:[UIImage imageWithColor:STRCOLOR(@"#3771E6")]
                                                  forBarPosition:UIBarPositionTopAttached
                                                      barMetrics:UIBarMetricsDefault];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent=YES;
    self.title = @"消息";
    self.view.backgroundColor = BackGroundColor;

    // Do any additional setup after loading the view from its nib.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar  setBackgroundImage:[UIImage imageWithColor:STRCOLOR(@"#3771E6")]
                                                  forBarPosition:UIBarPositionTopAttached
                                                      barMetrics:UIBarMetricsDefault];
    self.titleLabel.textColor = [UIColor whiteColor];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    NSLog(@"%@",self.view);
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

#pragma mark - 均分下划线
- (void)segmentStyle{
    list = @[@"全部",
             @"未读",
             @"已读",
             ];
    self.segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0,kNAVIGATIONBARHEIGHT, SCREEN_WIDTH, 40) titles:list headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutDefault];
    self.segHead.fontScale = .85;
    self.segHead.fontSize = 14;
    self.segHead.selectColor =STRCOLOR(@"#3771E6");
    self.segHead.lineScale = .9;
    self.segHead.lineHeight = 2;
    self.segHead.lineColor = STRCOLOR(@"#3771E6");
    self.segHead.bottomLineColor = [UIColor groupTableViewBackgroundColor];
    CGFloat m = kSCREEN_W/3;
    self.segHead.lineScale = 30/m;
    self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT-CGRectGetMaxY(_segHead.frame)) vcOrViews:[self vcArr:list.count]];
    self.segScroll.loadAll = NO;
//    self.segScroll.showIndex = 2;
    WeakSelf(self);
    [MLMSegmentManager associateHead:self.segHead withScroll:self.segScroll completion:^{
        [weakSelf.view addSubview:self.segHead];
        [weakSelf.view addSubview:self.segScroll];
    }];
}
- (NSArray *)vcArr:(NSInteger)count {
    NSMutableArray *arr = [NSMutableArray array];
    for (NSInteger i = 0; i < count; i ++) {
        AllMessageViewController * vc = [AllMessageViewController new];
        vc.title =[NSString stringWithFormat:@"--%ld",i];
        [arr addObject:vc];
    }
    return arr;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
